<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Section 18.2.&nbsp; Overview</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch18lev1sec1.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch18lev1sec3.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="ch18lev1sec2"></a>
<h3 class="docSection1Title">18.2. Overview</h3>
<p class="docText">Terminal I/O has two modes:</P>
<div style="font-weight:bold"><ol class="docList" type="1"><LI><div style="font-weight:normal"><p class="docList">Canonical mode input processing. In this mode, terminal input is processed as lines. The terminal driver returns at most one line per read request.</p></div></LI><LI><div style="font-weight:normal"><p class="docList">Noncanonical mode input processing. The input characters are not assembled into lines.</P></div></li></ol></div>
<p class="docText"><a name="idd1e132473"></a><a name="idd1e132476"></a><a name="idd1e132479"></a><a name="idd1e132484"></a><a name="idd1e132487"></a><a name="idd1e132492"></a><a name="idd1e132497"></a><a name="idd1e132502"></a><a name="idd1e132507"></a><a name="idd1e132512"></a>If we don't do anything special, canonical mode is the default. For example, if the shell redirects standard input to the terminal and we use <tt>read</tt> and <tt>write</tt> to copy standard input to standard output, the terminal is in canonical mode, and each <tt>read</tt> returns at most one line. Programs that manipulate the entire screen, such as the <tt>vi</tt> editor, use noncanonical mode, since the commands may be single characters and are not terminated by newlines. Also, this editor doesn't want processing by the system of the special characters, since they may overlap with the editor commands. For example, the Control-D character is often the end-of-file character for the terminal, but it's also a <tt>vi</tt> command to scroll down one-half screen.</P>
<blockquote>
<p class="docText">The Version 7 and older BSD-style terminal drivers supported three modes for terminal input: (a) cooked mode (the input is collected into lines, and the special characters are processed), (b) raw mode (the input is not assembled into lines, and there is no processing of special characters), and (c) cbreak mode (the input is not assembled into lines, but some of the special characters are processed). <a class="docLink" href="ch18lev1sec11.html#ch18fig20">Figure 18.20</a> shows a POSIX.1 function that places a terminal in cbreak or raw mode.</P>
</blockquote>
<p class="docText">POSIX.1 defines 11 special input characters, 9 of which we can change. We've been using some of these throughout the text: the end-of-file character (usually Control-D) and the suspend character (usually Control-Z), for example. <a class="docLink" href="ch18lev1sec3.html#ch18lev1sec3">Section 18.3</a> describes each of these characters.</P>
<p class="docText">We can think of a terminal device as being controlled by a terminal driver, usually within the kernel. Each terminal device has an input queue and an output queue, shown in <a class="docLink" href="#ch18fig01">Figure 18.1</a>.</p>
<a name="ch18fig01"></a><P><center>
<h5 class="docFigureTitle">Figure 18.1. Logical picture of input and output queues for a terminal device</H5>
<p class="docText"><div class="v1"><a target="_self" href="images/0201433079/graphics/18fig01_alt.gif;423615">[View full size image]</a></div><img border="0" alt="" width="500" height="176" SRC="images/0201433079/graphics/18fig01.gif;423615"></P>
</center></P><br>
<p class="docText">There are several points to consider from this picture.</P>
<UL><li><p class="docList">If echoing is enabled, there is an implied link between the input queue and the output queue.</P></LI><li><p class="docList">The size of the input queue, <tt>MAX_INPUT</tt> (see <a class="docLink" href="ch02lev1sec5.html#ch02fig11">Figure 2.11</a>), is finite. When the input queue for a particular device fills, the system behavior is implementation dependent. Most UNIX systems echo the bell character when this happens.</p></li><li><p class="docList"><a name="idd1e132602"></a><a name="idd1e132607"></a><a name="idd1e132612"></a>There is another input limit, <tt>MAX_CANON</tt>, that we don't show here. This limit is the maximum number of bytes in a canonical input line.</P></li><LI><p class="docList">Although the size of the output queue is finite, no constants defining that size are accessible to the program, because when the output queue starts to fill up, the kernel simply puts the writing process to sleep until room is available.</p></LI><li><p class="docList">We'll see how the <tt>tcflush</tt> flush function allows us to flush either the input queue or the output queue. Similarly, when we describe the <tt>tcsetattr</tt> function, we'll see how we can tell the system to change the attributes of a terminal device only after the output queue is empty. (We want to do this, for example, if we're changing the output attributes.) We can also tell the system to discard everything in the input queue when changing the terminal attributes. (We want to do this if we're changing the input attributes or changing between canonical and noncanonical modes, so that previously entered characters aren't interpreted in the wrong mode.)</p></li></ul>
<p class="docText">Most UNIX systems implement all the canonical processing in a module called the <span class="docEmphasis">terminal line discipline</span>. We can think of this module as a box that sits between the kernel's generic read and write functions and the actual device driver (see <a class="docLink" href="#ch18fig02">Figure 18.2</a>).</p>
<a name="ch18fig02"></a><p><center>
<h5 class="docFigureTitle">Figure 18.2. Terminal line discipline</h5>

<p class="docText">
<img border="0" alt="" width="245" height="423" SRC="images/0201433079/graphics/18fig02.gif;423615"></p>

</center></p><br>
<p class="docText">Note the similarity of this picture and the diagram of a stream shown in <a class="docLink" href="ch14lev1sec4.html#ch14fig14">Figure 14.14</a>. We'll return to this picture in <a class="docLink" href="ch19.html#ch19">Chapter 19</a>, when we discuss pseudo terminals.</p>
<p class="docText"><a name="idd1e132678"></a><a name="idd1e132683"></a><a name="idd1e132688"></a><a name="idd1e132691"></a><a name="idd1e132696"></a><a name="idd1e132699"></a><a name="idd1e132702"></a><a name="idd1e132707"></a><a name="idd1e132712"></a><a name="idd1e132717"></a><a name="idd1e132722"></a><a name="idd1e132727"></a><a name="idd1e132732"></a><a name="idd1e132737"></a><a name="idd1e132742"></a>All the terminal device characteristics that we can examine and change are contained in a <tt>termios</tt> structure. This structure is defined in the header <tt>&lt;termios.h&gt;</tt>, which we use throughout this chapter:</p>

<pre>
   struct termios {
     tcflag_t  c_iflag;    /* input flags */
     tcflag_t  c_oflag;    /* output flags */
     tcflag_t  c_cflag;    /* control flags */
     tcflag_t  c_lflag;    /* local flags */
     cc_t      c_cc[NCCS]; /* control characters */
   };
</pre><br>

<p class="docText">Roughly speaking, the input flags control the input of characters by the terminal device driver (strip eighth bit on input, enable input parity checking, etc.), the output flags control the driver output (perform output processing, map newline to CR/LF, etc.), the control flags affect the RS-232 serial lines (ignore modem status lines, one or two stop bits per character, etc.), and the local flags affect the interface between the driver and the user (echo on or off, visually erase characters, enable terminal-generated signals, job control stop signal for background output, etc.).</p>
<p class="docText">The type <tt>tcflag_t</tt> is big enough to hold each of the flag values and is often defined as an <tt>unsigned int</tt> or an <tt>unsigned long</tt>. The <tt>c_cc</tt> array contains all the special characters that we can change. <tt>NCCS</tt> is the number of elements in this array and is typically between 15 and 20 (since most implementations of the UNIX System support more than the 11 POSIX-defined special characters). The <tt>cc_t</tt> type is large enough to hold each special character and is typically an <tt>unsigned char</tt>.</p>
<blockquote>
<p class="docText">Versions of System V that predated the POSIX standard had a header named <tt>&lt;termio.h&gt;</tt> and a structure named <tt>termio</tt>. POSIX.1 added an <tt>s</tt> to the names, to differentiate them from their predecessors.</p>
</blockquote>
<p class="docText"><a class="docLink" href="#ch18fig03">Figures 18.3</a> through <a class="docLink" href="#ch18fig06">18.6</a> list all the terminal flags that we can change to affect the characteristics of a terminal device. Note that even though the Single UNIX Specification defines a common subset that all platforms start from, all the implementations have their own additions. Most of these additions come from the historical differences between the systems. We'll discuss each of these flag values in detail in <a class="docLink" href="ch18lev1sec5.html#ch18lev1sec5">Section 18.5</a>.</P>
<a name="ch18fig03"></a><P><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><h5 class="docTableTitle">Figure 18.3. <tt>c_cflag</tt> terminal flags</H5></caption><colgroup><col width="70"><col width="200"><col width="40"><col width="40"><col width="40"><col width="40"><col width="40"></colgroup><thead><TR><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Flag</span></P></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Description</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">POSIX.1</span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">FreeBSD 5.2.1</span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Linux 2.4.22</span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Mac OS X 10.3</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Solaris 9</span></P></th></tr></thead><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>CBAUDEXT</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">extended baud rate</P></td><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>CCAR_OFLOW</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">DCD flow control of output</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>CCTS_OFLOW</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">CTS flow control of output</P></td><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>CDSR_OFLOW</tt></p></TD><td class="rightBorder" align="left" valign="top"><p class="docText">DSR flow control of output</P></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>CDTR_IFLOW</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">DTR flow control of input</p></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>CIBAUDEXT</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">extended input baud rate</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>CIGNORE</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">ignore control flags</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>CLOCAL</tt></p></TD><td class="rightBorder" align="left" valign="top"><p class="docText">ignore modem status lines</P></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>CREAD</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">enable receiver</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>CRTSCTS</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">enable hardware flow control</P></td><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>CRTS_IFLOW</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText">RTS flow control of input</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>CRTSXOFF</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">enable input hardware flow control</p></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>CSIZE</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">character size mask</p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>CSTOPB</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">send two stop bits, else one</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>HUPCL</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">hang up on last close</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>MDMBUF</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">same as <tt>CCAR_OFLOW</tt></p></td><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>PARENB</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">parity enable</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>PAREXT</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">mark or space parity</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>PARODD</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">odd parity, else even</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr></table></P><br>
<a name="ch18fig04"></a><p><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><h5 class="docTableTitle">Figure 18.4. <tt>c_iflag</tt> terminal flags</h5></caption><colgroup><col width="70"><col width="150"><col width="40"><col width="40"><col width="40"><col width="40"><col width="40"></colgroup><thead><tr><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Flag</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Description</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">POSIX.1</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">FreeBSD 5.2.1</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Linux 2.4.22</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Mac OS X 10.3</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Solaris 9</span></p></th></tr></thead><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>BRKINT</tt></p></td><TD class="rightBorder" align="left" valign="top"><p class="docText">generate <tt>SIGINT</tt> on BREAK</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICRNL</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText">map CR to NL on input</p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IGNBRK</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">ignore BREAK condition</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>IGNCR</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">ignore CR</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IGNPAR</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">ignore characters with parity errors</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IMAXBEL</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">ring bell on input queue full</P></TD><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>INLCR</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">map NL to CR on input</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>INPCK</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">enable input parity checking</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ISTRIP</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">strip eighth bit off input characters</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>IUCLC</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">map uppercase to lowercase on input</P></td><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IXANY</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">enable any characters to restart output</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IXOFF</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">enable start/stop input flow control</p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IXON</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText">enable start/stop output flow control</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>PARMRK</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">mark parity errors</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr></table></P><br>
<a name="ch18fig05"></a><P><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><h5 class="docTableTitle">Figure 18.5. <tt>c_lflag</tt> terminal flags</H5></caption><colgroup><col width="50"><col width="150"><col width="40"><col width="40"><col width="40"><col width="40"><col width="40"></colgroup><thead><tr><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Flag</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Description</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">POSIX.1</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">FreeBSD 5.2.1</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Linux 2.4.22</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Mac OS X 10.3</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Solaris 9</span></p></th></tr></thead><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ALTWERASE</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">use alternate WERASE algorithm</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ECHO</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">enable echo</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ECHOCTL</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">echo control chars as ^(Char)</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ECHOE</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">visually erase chars</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ECHOK</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">echo kill</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ECHOKE</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">visual erase for kill</p></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ECHONL</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">echo NL</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ECHOPRT</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">visual erase mode for hard copy</P></td><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>EXTPROC</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">external character processing</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>FLUSHO</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">output being flushed</P></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">canonical input</p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IEXTEN</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">enable extended input char processing</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ISIG</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">enable terminal-generated signals</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>NOFLSH</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">disable flush after interrupt or quit</p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>NOKERNINFO</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">no kernel output from STATUS</P></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>PENDIN</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">retype pending input</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>TOSTOP</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">send <tt>SIGTTOU</tt> for background output</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>XCASE</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">canonical upper/lower presentation</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></TR></table></P><br>
<a name="ch18fig06"></a><P><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><H5 class="docTableTitle">Figure 18.6. <tt>c_oflag</tt> terminal flags</H5></caption><colgroup><col width="70"><col width="150"><col width="40"><col width="40"><col width="40"><col width="40"><col width="40"></colgroup><thead><tr><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Flag</span></P></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Description</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">POSIX.1</span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">FreeBSD 5.2.1</span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Linux 2.4.22</span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Mac OS X 10.3</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Solaris 9</span></P></th></TR></thead><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>BSDLY</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText">backspace delay mask</p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>CMSPAR</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">mark or space parity</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="left" valign="top">&nbsp;</TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>CRDLY</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">CR delay mask</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>FFDLY</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">form feed delay mask</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>NLDLY</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">NL delay mask</p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">XSI</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>OCRNL</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">map CR to NL on output</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>OFDEL</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">fill is DEL, else NUL</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">XSI</P></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>OFILL</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">use fill character for delay</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>OLCUC</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">map lowercase to uppercase on output</p></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ONLCR</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">map NL to CR-NL</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ONLRET</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">NL performs CR function</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ONOCR</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">no CR output at column 0</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">XSI</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ONOEOT</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">discard EOTs (^D) on output</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>OPOST</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">perform output processing</p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>OXTABS</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText">expand tabs to spaces</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>TABDLY</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">horizontal tab delay mask</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">XSI</P></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VtdLY</tt></p></td><TD class="rightBorder" align="left" valign="top"><p class="docText">vertical tab delay mask</p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">XSI</P></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr></table></p><br>
<p class="docText">Given all the options available, how do we examine and change these characteristics of a terminal device? <a class="docLink" href="#ch18fig07">Figure 18.7</a> summarizes the various functions defined by the Single UNIX Specification that operate on terminal devices. (All the functions listed are part of the base POSIX specification, except for <tt>tcgetsid</tt>, which is an XSI extension. We described <tt>tcgetpgrp</tt>, <tt>tcgetsid</tt>, and <tt>tcsetpgrp</tt> in <a class="docLink" href="ch09lev1sec7.html#ch09lev1sec7">Section 9.7</a>.)</p>
<a name="ch18fig07"></a><p><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><h5 class="docTableTitle">Figure 18.7. Summary of terminal I/O functions</H5></caption><colgroup><col width="150"><col width="350"></colgroup><thead><TR><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><a name="idd1e135113"></a><a name="idd1e135118"></a><a name="idd1e135123"></a><a name="idd1e135128"></a><a name="idd1e135133"></a><a name="idd1e135138"></a><a name="idd1e135143"></a><a name="idd1e135148"></a><a name="idd1e135153"></a><a name="idd1e135158"></a><a name="idd1e135163"></a><a name="idd1e135168"></a><a name="idd1e135173"></a><a name="idd1e135178"></a><a name="idd1e135183"></a><a name="idd1e135188"></a><a name="idd1e135193"></a><span class="docEmphRoman">Function</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Description</span></P></th></TR></thead><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>tcgetattr</tt></P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">fetch attributes (<tt>termios</tt> structure)</p></TD></tr><TR><TD class="rightBorder bottomBorder" align="left" valign="top"><p class="docText"><tt>tcsetattr</tt></P></td><TD class="bottomBorder" align="left" valign="top"><p class="docText">set attributes (<tt>termios</tt> structure)</P></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>cfgetispeed</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">get input speed</P></td></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>cfgetospeed</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">get output speed</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>cfsetispeed</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">set input speed</p></td></tr><tr><td class="rightBorder bottomBorder" align="left" valign="top"><p class="docText"><tt>cfsetospeed</tt></p></TD><TD class="bottomBorder" align="left" valign="top"><p class="docText">set output speed</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>tcdrain</tt></P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">wait for all output to be transmitted</p></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>tcflow</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">suspend transmit or receive</P></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>tcflush</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">flush pending input and/or output</P></td></TR><tr><TD class="rightBorder bottomBorder" align="left" valign="top"><p class="docText"><tt>tcsendbreak</tt></p></td><td class="bottomBorder" align="left" valign="top"><p class="docText">send BREAK character</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>tcgetpgrp</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">get foreground process group ID</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>tcsetpgrp</tt></p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">set foreground process group ID</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>tcgetsid</tt></P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">get process group ID of session leader for controlling<br>TTY (XSI extension)</P></td></TR></table></P><BR>
<p class="docText">Note that the Single UNIX Specification doesn't use the classic <tt>ioctl</tt> on terminal devices. Instead, it uses the 13 functions shown in <a class="docLink" href="#ch18fig07">Figure 18.7</a>. The reason is that the <tt>ioctl</tt> function for terminal devices uses a different data type for its final argument, which depends on the action being performed. This makes type checking of the arguments impossible.</p>
<p class="docText"><a name="idd1e135390"></a><a name="idd1e135395"></a><a name="idd1e135400"></a><a name="idd1e135405"></a><a name="idd1e135410"></a><a name="idd1e135415"></a><a name="idd1e135420"></a><a name="idd1e135425"></a><a name="idd1e135430"></a><a name="idd1e135435"></a><a name="idd1e135440"></a><a name="idd1e135445"></a><a name="idd1e135450"></a><a name="idd1e135455"></a><a name="idd1e135460"></a><a name="idd1e135465"></a><a name="idd1e135468"></a><a name="idd1e135473"></a><a name="idd1e135478"></a><a name="idd1e135483"></a><a name="idd1e135488"></a><a name="idd1e135493"></a><a name="idd1e135498"></a><a name="idd1e135503"></a><a name="idd1e135508"></a><a name="idd1e135513"></a><a name="idd1e135518"></a><a name="idd1e135523"></a><a name="idd1e135528"></a><a name="idd1e135533"></a><a name="idd1e135536"></a><a name="idd1e135539"></a><a name="idd1e135544"></a><a name="idd1e135549"></a><a name="idd1e135554"></a><a name="idd1e135559"></a><a name="idd1e135564"></a><a name="idd1e135567"></a><a name="idd1e135572"></a>Although only 13 functions operate on terminal devices, the first two functions in <a class="docLink" href="#ch18fig07">Figure 18.7</a> (<tt>tcgetattr</tt> and <tt>tcsetattr</tt>) manipulate almost 70 different flags (see <a class="docLink" href="#ch18fig03">Figures 18.3</a> through <a class="docLink" href="#ch18fig06">18.6</a>). The handling of terminal devices is complicated by the large number of options available for terminal devices and trying to determine which options are required for a particular device (be it a terminal, modem, printer, or whatever).</P>
<p class="docText"><a name="idd1e135598"></a><a name="idd1e135601"></a><a name="idd1e135606"></a><a name="idd1e135611"></a><a name="idd1e135616"></a><a name="idd1e135621"></a><a name="idd1e135626"></a><a name="idd1e135631"></a><a name="idd1e135636"></a><a name="idd1e135641"></a><a name="idd1e135644"></a><a name="idd1e135649"></a><a name="idd1e135654"></a><a name="idd1e135659"></a><a name="idd1e135664"></a><a name="idd1e135669"></a><a name="idd1e135674"></a><a name="idd1e135679"></a><a name="idd1e135684"></a><a name="idd1e135689"></a><a name="idd1e135694"></a><a name="idd1e135699"></a><a name="idd1e135704"></a><a name="idd1e135709"></a><a name="idd1e135714"></a><a name="idd1e135719"></a><a name="idd1e135724"></a><a name="idd1e135729"></a><a name="idd1e135734"></a><a name="idd1e135739"></a><a name="idd1e135744"></a><a name="idd1e135749"></a><a name="idd1e135754"></a><a name="idd1e135759"></a><a name="idd1e135764"></a>The relationships among the 13 functions shown in <a class="docLink" href="#ch18fig07">Figure 18.7</a> are shown in <a class="docLink" href="#ch18fig08">Figure 18.8</a>.</P>
<a name="ch18fig08"></a><p><center>
<H5 class="docFigureTitle">Figure 18.8. Relationships among the terminal-related functions</H5>
<p class="docText"><div class="v1"><a target="_self" href="images/0201433079/graphics/18fig08_alt.gif;423615">[View full size image]</a></div><img border="0" alt="" width="500" height="302" SRC="images/0201433079/graphics/18fig08.gif;423615"></p>
</center></p><br>
<p class="docText">POSIX.1 doesn't specify where in the <tt>termios</tt> structure the baud rate information is stored; that is an implementation detail. Some systems, such as Linux and Solaris, store this information in the <tt>c_cflag</tt> field. BSD-derived systems, such as FreeBSD and Mac OS X, have two separate fields in the structure: one for the input speed and one for the output speed.</p>

<a href="17021535.html"><img src="images/pixel.gif" alt="" width="1" height="1" border="0"></a><UL></ul></TD></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch18lev1sec1.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch18lev1sec3.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html><br>
<table width="100%" cellspacing="0" cellpadding="0"
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color=white; border-top: 1px solid gray;"> 
<a href="http://www.zipghost.com/" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">The CHM file was converted to HTM by Trial version of <b>ChmD<!--121-->ecompiler</b>.</a>
</TD>
</TR><tr>
<td align="right" style="background-color=white; "> 
<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">Download <b>ChmDec<!--121-->ompiler</b> at: http://www.zipghost.com</a>
</TD></tr></table>
